package com.project.yuepai.controller.admin;

import com.project.yuepai.dto.MessageBean;
import com.project.yuepai.service.SuggestService;
import com.project.yuepai.util.MessageUtil;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/admin/suggest")
public class SuggestController {

    @Autowired
    private SuggestService suggestService;

    @RequestMapping(value = "/getAllFeedback.action",method = RequestMethod.GET)
    public MessageBean getAllFeedback(@NotNull(message = "页面数据条数不能为空") Integer limit,@NotNull(message = "页号不能为空") Integer page,String nickName,Integer userRole,String userPhone){
        System.out.println("nickName-->"+nickName+" userRole-->"+userRole+" userPhone--> "+userPhone);
        return MessageUtil.success("获取成功！",suggestService.listFeedback(page,limit,nickName,userRole,userPhone));
    }

    @RequestMapping(value = "/deleteFeedback.action",method = RequestMethod.DELETE)
    public MessageBean deleteFeedback(Integer feedbackId){
        System.out.println("feedbackId"+feedbackId);
        if(suggestService.deleteFeedback(feedbackId))
            return MessageUtil.success("删除成功！");
        return MessageUtil.failure("删除失败！");
    }



}
